package com.ellecity06.common.utils

import android.annotation.SuppressLint
import android.util.Log
import com.ellecity06.common.BuildConfig

/**
 * @author ellecity06
 * @time 2023/3/29 15:17
 * @des
 */
private const val TAG = "JDG_TEST_LOG"

@SuppressLint("LongLogTag")
fun logD(content: String, tag: String = "", tr: Throwable? = null) {
    if (BuildConfig.BUILD_TYPE == "release") return
    Log.d("${TAG}-${tag}", content, tr)
}

fun logE(content: String, tag: String = TAG, tr: Throwable? = null) {
    if (BuildConfig.BUILD_TYPE == "release") return
    Log.e(tag, content, tr)
}

fun debugLog(message: Any) {
    val adjustMessage = if (message is Throwable) {
        message.stackTraceToString()
    } else {
        val occurred = Throwable().stackTrace.getOrNull(1)?.run { " (${fileName}:${lineNumber})" } ?: ""
        message.toString() + occurred
    }
    Log.d(TAG, adjustMessage)
}
